<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>后台广告添加</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__ADMIN__css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="__ADMIN__css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="__ADMIN__css/animate.min.css" rel="stylesheet">
    <link href="__ADMIN__css/style.min862f.css" rel="stylesheet">
    <link href="__ADMIN__js/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="__ADMIN__css/plugins/switchery/switchery.css" rel="stylesheet">
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加广告</h5>
                </div>
                <div class="ibox-content">
                    <form method="post" name="forma" id="forma" action="{:U('Poster/save')}" class="form-horizontal" enctype="multipart/form-data">
                        <input type="hidden" name="spaceid" value="{$spaceInfo['id']}" />
                        <input type="hidden" name="id" value="{$data.id}">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">排序</label>

                            <div class="col-sm-10">
                                <input type="text" name="sort" id="sort" class="form-control" value="{$data.sort}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">广告名称</label>

                            <div class="col-sm-10">
                                <input type="text" name="title" id="title" class="form-control" value="{$data.title}">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">头像上传</label>

                            <div class="col-sm-10">
                                <input type="file" name="setting" id="setting" aria-required="true" aria-invalid="false"/>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">广告类型</label>

                            <div class="col-sm-10">
                                <select class="form-control m-b" name="type" id="type" disabled>
                                    <option value="1" <if condition="$spaceInfo['type'] eq 1">selected</if>>选项 1</option>
                                    <option value="2" <if condition="$spaceInfo['type'] eq 2">selected</if>>选项 2</option>
                                    <option value="3" <if condition="$spaceInfo['type'] eq 3">selected</if>>选项 3</option>
                                    <option value="4" <if condition="$spaceInfo['type'] eq 4">selected</if>>选项 4</option>
                                </select>
                                <input type="hidden" id="type1" name="type1">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">所属版位</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" value="{$spaceInfo['name']}" readonly>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上线时间：</label>
                            <div class="col-sm-10">
                                <input type="text" class="laydate-icon input w50" id="start" name="start" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" value="{$adInfo.downtime}" data-validate="required:日期不能为空" style="padding:10px!important; height:auto!important;border:1px solid #ddd!important;" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">下线时间：</label>
                            <div class="col-sm-10">
                                <input type="text" class="laydate-icon input w50" id="end" name="end" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" value="{$adInfo.downtime}" data-validate="required:日期不能为空" style="padding:10px!important; height:auto!important;border:1px solid #ddd!important;" />
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">状态</label>

                            <div class="col-sm-10">
                                <input type="checkbox" value="1" name="status" id="status" class="js-switch" <if condition="$poster['status'] eq 1">checked</if> checked>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">保存内容</button>
                                <button class="btn btn-white" type="reset"  onclick="history.go(-1)">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__ADMIN__js/jquery.min.js"></script>
<script src="__ADMIN__js/bootstrap.min.js"></script>
<script src="__ADMIN__js/plugins/layer/layer.min.js"></script>
<script src="__ADMIN__js/plugins/layer.3/layer.js"></script>
<script src="__ADMIN__js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="__ADMIN__js/plugins/switchery/switchery.js"></script>
<script src="__ADMIN__js/plugins/validate/jquery.validate.min.js"></script>
<script src="__ADMIN__js/plugins/validate/messages_zh.min.js"></script>
<script src="__ADMIN__js/common.js"></script>
<script src="__ADMIN__js/plugins/layer/laydate/laydate.js"></script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script>
    $(function(){
        document.getElementById('type1').value = document.getElementById('type').value;
        $("#forma").validate({
            rules:{
                title:"required"
            },
            messages:{
                title:'广告名不能为空!'
            },
            submitHandler: function (form){
                var forma = new FormData(document.getElementById('forma'));
//                console.log(forma);
                $.ajax({
                    url:$(form).attr('action'),
                    type:'post',
                    dataType:'json',
                    data:forma,
                    cache:false,
                    processData:false,
                    contentType:false,
                    success:function(data){
                        if(data.status > 0){
                            common.error(data.msg);
                        }else{
                            common.success(data.msg,"{:U('poster/index?spaceid='.$spaceInfo['id'])}");
                        }
                    }
                });
            }
        });
    });
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, { });
</script>
</body>
</html>
